/* Copyright (C) 2008  Romolo Camplani, Marco Fortunato, Marco Marelli, Guido Rota, Fabio A. Schreiber et al.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */
/*
 * AppSoft.java
 *
 * Created on October 24, 2007, 9:08 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package org.dei.perla.utils.emulator.model.node;


import org.dei.perla.utils.emulator.models.meta.Component;
import org.dei.perla.utils.emulator.models.net.NetCommAppSoft;

/**
 *
 * @author Adnan
 */
public class AppSoft implements Component, NetCommAppSoft{
    
    /** Creates a new instance of AppSoft */
    private SensorBoard sbOfLocal;
    
    private AppsoftSensor asofts;
    
    public AppSoft() {
    }
    
     public void setReference(SensorBoard sbOfNode)
    {
        sbOfLocal = sbOfNode;
    }
     
    public void sendData(String s){
        
        asofts = sbOfLocal;
       String []parsed = s.split(" ");
       // System.out.println("Parsed string is ");
      //  for(String ss:parsed)
       //     System.out.println(ss);
        
        if (parsed[0].equalsIgnoreCase(new String("charge")))
            asofts.setCharge(Double.parseDouble(parsed[1]));
    }
    
    public String getData(String s){
        asofts = sbOfLocal;
        if (s.equalsIgnoreCase(new String("charge")))
            return asofts.getCharge();
         return "";
    }
}
